//
// Created by root on 4/29/17.
//

#include "../runner.h"

static void test_op_make_lambda() {
    assert_string_equal(interpret("(lambda () ())"), "#<Closure>: ");
    assert_string_equal(interpret("(lambda (a b) (+ a b))"), "#<Closure>: ");
}

static void test_op_make_def() {
    assert_string_equal(interpret("(define x 123)"), "x");
    assert_string_equal(interpret("(define add5 (lambda (x) (+ x 5)))"), "add5");
    assert_string_equal(interpret("(define (add6 x) (+ x 6))"), "add6");
    assert_string_equal(interpret("(define fix (lambda (x y z) (define add (lambda (a b) (+ a b))) (- x (add y z))))"), "fix");
}

//TODO
static void test_op_make_set() {
}

//TODO
static void test_op_make_gensym() {
}

//TODO
static void test_op_make_oblist() {
}

static void test_op_make_gc() {
    assert_string_equal(interpret("(gc)"), "#t");
}

static void test_op_make_gcverb() {
    assert_string_equal(interpret("(gc-verbose)"), "#t");
}

int main(int argc, char **argv) {
    const struct CMUnitTest tests[] = {
            cmocka_unit_test(test_op_make_lambda),
            cmocka_unit_test(test_op_make_def),
            cmocka_unit_test(test_op_make_set),
            cmocka_unit_test(test_op_make_gensym),
            cmocka_unit_test(test_op_make_oblist),
            cmocka_unit_test(test_op_make_gc),
            cmocka_unit_test(test_op_make_gcverb),
    };
    return cmocka_run_group_tests(tests, setup_scheme, teardown_scheme);
}
